package org.example.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.example.pojo.entity.AddressBook;

import java.util.List;

@Mapper
public interface AddressMapper {

    public List<AddressBook> list(AddressBook addressBook);

    @Insert("insert into address_book(userid, consignee,  province, city, district, detail, label, is_default) " +
            "values (#{userid},#{consignee},#{province},#{city},#{district},#{detail},#{label},#{isdefault})")
    public void insert(AddressBook addressBook);

    public void update(AddressBook address);

    @Update("update address_book set is_default = 0 where userid=#{userid}")
    public void setnodefault(AddressBook address);

    @Update("update address_book set is_default = 1 where id=#{id}")
    public void setdefault(AddressBook address);

    @Select("select * from webwork.address_book where id = #{id}")
    public AddressBook findById(int id);
}
